package com.wang.mall.controller;

import com.wang.mall.model.R;
import com.wang.mall.service.ProductService;
import com.wang.mall.vo.LockStockResult;
import com.wang.mall.vo.WareProductLockVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/ware")
public class WareController {


    @Autowired
    private ProductService productService;

    /**
     * 为订单锁定库存
     *
     * @param lockVo
     * @return
     */
    @PostMapping("/lock/order")
    public R<List<LockStockResult>> orderLock(@RequestBody WareProductLockVo lockVo) {
        List<LockStockResult> lockStockResults = productService.orderLock(lockVo);

        return R.ok(lockStockResults);
    }
}
